/**
 * Class: MeshTest
 *
 * Purpose: 
 *
 * Created: Feb 19, 2010 @ 1:36:30 PM
 * @author Ken Scott
 */
package org.openfantasia.ps.shape;

import org.openfantasia.ps.particle.Particle;
import org.openfantasia.ui.PFrame;
import org.openfantasia.util.math.DPoint3;

public class Grid extends Shape {

	private int hCount = 10;

	private int vCount = 10;


	public Grid(PFrame frame) {
		super(frame);
	}


	public Grid(PFrame frame, int hCount, int vCount) {
		super(frame);
		this.hCount = hCount;
		this.vCount = vCount;
	}


	public void drawShape(Particle particle) {
		DPoint3 size = getSize(particle);
		double hStep = 1.0 / (double) hCount;
		double vStep = 1.0 / (double) vCount;

		frame.beginShape(PFrame.LINES);
		DPoint3 from;
		DPoint3 to;
		double min = -0.5;
		double max = 0.5;
		for (int h = 0; h <= hCount; h++) {
			from = new DPoint3(min + (h * hStep), min, 0);
			to = new DPoint3(min + (h * hStep), max, 0);
			frame.line(from, to);
		}

		for (int v = 0; v <= vCount; v++) {
			from = new DPoint3(min, min + (v * vStep), 0);
			to = new DPoint3(max, min + (v * vStep), 0);
			frame.line(from, to);
		}
		frame.endShape(PFrame.LINES);
	}
}